package com.zhouxiaoge.集合;

import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;

/**
 * @author 周明阳
 * mail:gqzmy@outlook.com
 * 时间:2018-04-28 10:28
 */

public class LinkedListTest {
    public static void main(String[] args) {
        List<String> a = new LinkedList<>();
        a.add("AAAA");
        a.add("ABBB");
        a.add("BCCC");

        List<String> b = new LinkedList<>();
        b.add("BAAA");
        b.add("BBBB");
        b.add("BCCC");
        b.add("BDDD");
        b.add("BEEE");

        ListIterator<String> aiterator = a.listIterator();
        Iterator<String> biterator = b.iterator();
        while (biterator.hasNext()) {
            if (aiterator.hasNext()) {
                aiterator.next();
            }
            aiterator.add(biterator.next());
        }
        System.out.println(a);
        biterator = b.iterator();
        while (biterator.hasNext()) {
            biterator.next();
            if (biterator.hasNext()) {
                biterator.next();
                biterator.remove();
            }
        }
        System.out.println(biterator);
        a.removeAll(b);
        System.out.println(a);
    }
}
